package org.ll.messageboard;

import ch.qos.logback.core.util.StringUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("Message")
public class MessageController {
    List<MessageInfo> messageiNFOList =  new ArrayList<>();

    @RequestMapping("/publish")
    public Boolean publish(MessageInfo message){
        if(StringUtil.isNullOrEmpty(message.getFrom()) || StringUtil.isNullOrEmpty(message.getTo()) || StringUtil.isNullOrEmpty(message.getMessage())){
            return false;
        }
        messageiNFOList.add(message);
        return true;
    }

    @RequestMapping("/getList")
    public List<MessageInfo> getMessageInfo(){
        return messageiNFOList;
    }
}
